package main

import (
	"fmt"
	"net/rpc"
)

type UserClient struct {
	*rpc.Client
}

var _ UserServiceInterface = (*UserClient)(nil)

func GetUserClient(network, address string) (*UserClient, error) {
	c, err := rpc.Dial(network, address)
	if err != nil {
		return nil, err
	}
	return &UserClient{Client: c}, nil
}
func (p *UserClient) Say(request string, reply *string) error {
	return p.Client.Call(UserServiceName+".Say", request, reply)
}

func main() {
	client, err := GetUserClient("tcp", "localhost:8012")
	if err != nil {
		panic(err)
	}

	var replay string
	err = client.Say("hi", &replay)
	if err != nil {
		panic(err)
	}
	fmt.Println(replay)
}
